<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  </head>
  <body style="">
    <div
      style="
        perspective: 800px;
        perspective-origin: 50%;
        width: 400px;
        height: 400px;
      "
    >
      <div class="box">
        <!-- <div class="box-axios">
          <img src="./rotation-arrow-counterclockwise.png" />
        </div> -->
        <div class="box-axios-y">
          <img src="./rotation-arrow-counterclockwise.png" />
        </div>

        <div class="box-dice">
          <div>F1</div>
          <div>F2</div>
          <div>F3</div>
          <div>F4</div>
          <div>F5</div>
          <div>F6</div>
        </div>
      </div>
    </div>

    <style>
      body {
        padding: 500px;
        background-color: #000;
      }
      .box {
        position: relative;
        height: 100px;
        width: 100px;

        transform-origin: center;
        transform-style: preserve-3d;
        animation: spinY 8s infinite linear;
      }

      .box-axios {
        position: absolute;
        transform-style: preserve-3d;
        transform: translateX(-120px) translateY(-10px) rotateY(90deg);
      }
      img {
        filter: invert(1);
      }

      .box-axios-y {
        position: absolute;
        transform-style: preserve-3d;
        transform: translateY(-120px) rotateX(90deg);
      }

      .box-dice {
        transform-style: preserve-3d;
      }
      .box-dice div {
        position: absolute;
        height: 100px;
        width: 100px;
        transform-style: preserve-3d;
        text-align: center;
        line-height: 100px;
        font-weight: bolder;
        font-size: 40px;
      }
      .box-dice div:nth-child(1) {
        background-color: yellow;
        transform: translateZ(50px);
      }
      .box-dice div:nth-child(2) {
        background-color: red;
        transform: translateY(50px) rotateX(270deg);
      }
      .box-dice div:nth-child(3) {
        background-color: blue;
        transform: translateZ(-50px) rotateX(0deg);
      }
      .box-dice div:nth-child(4) {
        background-color: green;
        transform: translateY(-50px) rotateX(90deg);
      }
      .box-dice div:nth-child(5) {
        background-color: violet;
        transform: translateX(50px) rotateY(90deg);
      }
      .box-dice div:nth-child(6) {
        background-color: aqua;
        transform: translateX(-50px) rotateY(270deg);
      }

      @keyframes spinX {
        0% {
          transform: rotateX(0deg);
        }
        50% {
          transform: rotateX(-180deg);
        }
        100% {
          transform: rotateX(-360deg);
        }
      }

      @keyframes spinY {
        0% {
          transform: rotateY(0deg);
        }
        50% {
          transform: rotateY(180deg);
        }
        100% {
          transform: rotateY(360deg);
        }
      }
    </style>
  </body>
</html>
